{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f6db9588",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 文本翻译-通用版"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "692e6b6f",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests \n",
    "\n",
    "# client_id 为官网获取的AK， client_secret 为官网获取的SK\n",
    "host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=【GiBcaR3GBRsYdMjdgdtvXQPT】&client_secret=【54bakhMvcCHSLaAzMCyblv5qUQlzsQTm】'\n",
    "response = requests.get(host)\n",
    "if response:\n",
    "    print(response.json())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "c69bbaae",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'24.ba09e12a29298d6c2f560350991a6375.2592000.1659012356.282335-25869222'"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "access_token"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8d1f95c8",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "95b225b1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\n",
      "    \"error_code\": \"0\",\n",
      "    \"error_msg\": \"success\",\n",
      "    \"data\": {\n",
      "        \"from\": \"zh\",\n",
      "        \"to\": \"en\",\n",
      "        \"content\": [\n",
      "            {\n",
      "                \"src\": \"这是一个测试 \",\n",
      "                \"dst\": \"This is a test\",\n",
      "                \"rect\": \"83 24 236 39\",\n",
      "                \"lineCount\": 1,\n",
      "                \"points\": [\n",
      "                    {\n",
      "                        \"x\": 80,\n",
      "                        \"y\": 22\n",
      "                    },\n",
      "                    {\n",
      "                        \"x\": 322,\n",
      "                        \"y\": 22\n",
      "                    },\n",
      "                    {\n",
      "                        \"x\": 322,\n",
      "                        \"y\": 65\n",
      "                    },\n",
      "                    {\n",
      "                        \"x\": 80,\n",
      "                        \"y\": 65\n",
      "                    }\n",
      "                ],\n",
      "                \"pasteImg\": \"\"\n",
      "            },\n",
      "            {\n",
      "                \"src\": \"这是一个例子 \",\n",
      "                \"dst\": \"This is an example\",\n",
      "                \"rect\": \"82 123 191 33\",\n",
      "                \"lineCount\": 1,\n",
      "                \"points\": [\n",
      "                    {\n",
      "                        \"x\": 79,\n",
      "                        \"y\": 122\n",
      "                    },\n",
      "                    {\n",
      "                        \"x\": 275,\n",
      "                        \"y\": 122\n",
      "                    },\n",
      "                    {\n",
      "                        \"x\": 275,\n",
      "                        \"y\": 158\n",
      "                    },\n",
      "                    {\n",
      "                        \"x\": 79,\n",
      "                        \"y\": 158\n",
      "                    }\n",
      "                ],\n",
      "                \"pasteImg\": \"\"\n",
      "            }\n",
      "        ],\n",
      "        \"sumSrc\": \"这是一个测试 \\n这是一个例子 \",\n",
      "        \"sumDst\": \"This is a test\\nThis is an example\",\n",
      "        \"pasteImg\": \"/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHBwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQkUDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wAARCADKAcoDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uH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0sYw1DUqfepgWF6UtIvSloAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAEwKNoNLRQA3y19KPLX0p1FADPKX0oMKHqtPooAYIUH8NHlr6U+igBuwelG0elOooATAowKWigBMCjApaKAEwKMClooATAo2ilooAbsHpRtHpTqKAEwKNo9KWigBuwelGxfSnUUAM8pfSjykP8NPooAZ5SjtS+WvpTqKAG+WvpQI1HQU6igAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAopuTSZoAfRTM0Z96AH0Uzd700sfWgCWiod/uacrZ70ASUU3JoyaAHUU3JoyaAHUU3JoyaAHUUzNLk0AOopuTTGYjvQBLRVcyt60gds9TSuBZoqEE46mnhiaYD6Kbk0ZNADqKQHNLQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUh6UtIelAHy/8AtU+HfiT4H8A+PfiD4c+MuvaPHp1o97aaHHpenSW0W0AbA7wNIR1PLE81veBfBPxB8O+Ek8Yav8Yte8UI2hyXn9lXumafFD5rW5ZW3RQK/wArHIGcHHOa1/20P+TVvib/ANgaX+YrqYP+SCRf9i0P/SWgDxH4Dftt+Brn4V+Ao/HfjdH8XanaRJe3j2UgtxcuThJZo4/Iic8fKWXqOOa9ctvFQH7QWo6K/jfzIo/Dq3w8JHTdqwKJgpvPtfQ5yF8vPHWvmvSfD2m2f/BKTyYbKFI08JyXYAQf67cz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fBPh6w8QyEs+q22lwx3TE9SZQoY5+tdYoYdjUgBHamIWnA5qHJJ6VKmfSgB606kApaACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//Z\"\n",
      "    }\n",
      "}\n"
     ]
    }
   ],
   "source": [
    "\n",
    "#   python ocr_translate.py <image>\n",
    "# ```\n",
    "# You may install `requests` to run this code: pip install requests\n",
    "# Please refer to `https://api.fanyi.baidu.com/doc/26` for complete api document\n",
    "\n",
    "import requests\n",
    "import random\n",
    "import json\n",
    "import os\n",
    "import sys\n",
    "from hashlib import md5\n",
    "\n",
    "\n",
    "file_name = '1.jpeg'\n",
    "\n",
    "url = 'https://aip.baidubce.com/file/2.0/mt/pictrans/v1?access_token=【24.ba09e12a29298d6c2f560350991a6375.2592000.1659012356.282335-25869222】'\n",
    "\n",
    "from_lang = 'zh'\n",
    "to_lang = 'en'\n",
    "\n",
    "# Build request\n",
    "payload = {'from': from_lang, 'to': to_lang, 'v': '3', 'paste': '1'}\n",
    "image = {'image': (os.path.basename(file_name), open(file_name, 'rb'), \"multipart/form-data\")}\n",
    "\n",
    "# Send request\n",
    "response = requests.post(url, params = payload, files = image)\n",
    "result = response.json()\n",
    "\n",
    "# Show response\n",
    "print(json.dumps(result, indent = 4, ensure_ascii = False))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "de80cb46",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "7af57738",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\n",
      "    \"error_code\": \"0\",\n",
      "    \"error_msg\": \"success\",\n",
      "    \"data\": {\n",
      "        \"from\": \"zh\",\n",
      "        \"to\": \"en\",\n",
      "        \"content\": [\n",
      "            {\n",
      "                \"src\": \"这是一个测试 \",\n",
      "                \"dst\": \"This is a test\",\n",
      "                \"rect\": \"83 24 236 39\",\n",
      "                \"lineCount\": 1,\n",
      "                \"points\": [\n",
      "                    {\n",
      "                        \"x\": 80,\n",
      "                        \"y\": 22\n",
      "                    },\n",
      "                    {\n",
      "                        \"x\": 322,\n",
      "                        \"y\": 22\n",
      "                    },\n",
      "                    {\n",
      "                        \"x\": 322,\n",
      "                        \"y\": 65\n",
      "                    },\n",
      "                    {\n",
      "                        \"x\": 80,\n",
      "                        \"y\": 65\n",
      "                    }\n",
      "                ],\n",
      "                \"pasteImg\": \"\"\n",
      "            },\n",
      "            {\n",
      "                \"src\": \"这是一个例子 \",\n",
      "                \"dst\": \"This is an example\",\n",
      "                \"rect\": \"82 123 191 33\",\n",
      "                \"lineCount\": 1,\n",
      "                \"points\": [\n",
      "                    {\n",
      "                        \"x\": 79,\n",
      "                        \"y\": 122\n",
      "                    },\n",
      "                    {\n",
      "                        \"x\": 275,\n",
      "                        \"y\": 122\n",
      "                    },\n",
      "                    {\n",
      "                        \"x\": 275,\n",
      "                        \"y\": 158\n",
      "                    },\n",
      "                    {\n",
      "                        \"x\": 79,\n",
      "                        \"y\": 158\n",
      "                    }\n",
      "                ],\n",
      "                \"pasteImg\": \"\"\n",
      "            }\n",
      "        ],\n",
      "        \"sumSrc\": \"这是一个测试 \\n这是一个例子 \",\n",
      "        \"sumDst\": \"This is a test\\nThis is an example\",\n",
      "        \"pasteImg\": \"/9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fT73UbsQS2yuc4ZTy2PSmXX7IfxX1L9pT4VfFDxJrFt4m1CwvTca3JFMsNvYxAEJFbxNywGeT3NfdlFABVHWdOXVtJvbFmKrcwvCWHYMpH9avUh6UAfGf7KXwm+OH7O+uyeB7nRdD1L4bPqlzejWkvgLlEkOeIup7VrePf2dviV8M/i/rHxK+CF7pkkuvgHWvDOrt5cFxIOkiN0U19aYFKOtAHxjc/AD40/tK+L9AuPjXLo3hzwZol0t6vhzRZ/Pa8mU5UyOOMA11Hxw/Z38e6b8ZLL4t/B2+06DxEtiNO1DRdTOy3vYV+7g9FI96+qKRjQB8MfEb4S/tKftQaZbeEPH1j4Z8D+DXuY59QbT7sXU86o2dq46Zr3b9oz4BSfFj9m/U/hxotylrOLKGCxknPy7ogAgY+h2jmvbyM0wrQB4P8Asup8Y9J8PpoHxQ8P6PpVppNlDaafd6ZerO1wEATLqPu/KBXudPNNBxSGIBzT80DmnAUCG0sYw1DUqfepgWF6UtIvSloAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKAEwKNoNLRQA3y19KPLX0p1FADPKX0oMKHqtPooAYIUH8NHlr6U+igBuwelG0elOooATAowKWigBMCjApaKAEwKMClooATAo2ilooAbsHpRtHpTqKAEwKNo9KWigBuwelGxfSnUUAM8pfSjykP8NPooAZ5SjtS+WvpTqKAG+WvpQI1HQU6igAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAopuTSZoAfRTM0Z96AH0Uz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pdzpmrWNtqenXKbJ7S7iWWKVfRlYEEexrC8K/CjwV4F0m+0vw54R0PQdNvgVurPTdOht4pwQQQ6IoDZBI59TXVYoxQBz6+BfDtt4R/4RWHQdNi8MfZzZ/2MlpGLPyCMGLysbNhBxtxisjV/gz4B8QnSDqngnw9qJ0iNYdON3pkMv2NF+6sW5TsA7BcYrtXGRTMH0NAHMN8MPB5d5P8AhFtG3vqS6yzfYIstfKuwXR+X/XBflEn3scZq9N4Z0mbxDDr0ml2b65BbtZxak0Cm4jgZgzRrJjcELAErnBIBrYNMIJPSkM8Z/aG+Bo+JXwm8ZaF4WsdJ0zxH4hls5ri+mj8kXDQ3EL5mkRCzEJEVBIPYcCu18P8Awk8HeHtb/wCEgtPCeh2fiaWMJcavbafEl1KcAHdKFDHPua7AqR1BpSD6UAZ9h4b0jT9a1DWLXS7O31bUVRby+igVZ7kINqCRwMttHAyTgdKxNJ+DfgHQ/E8niTTfBPh6w8QyEs+q22lwx3TE9SZQoY5+tdYoYdjUgBHamIWnA5qHJJ6VKmfSgB606kApaACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//Z\"\n",
      "    }\n",
      "}\n"
     ]
    }
   ],
   "source": [
    "\n",
    "#   python ocr_translate.py <image>\n",
    "# ```\n",
    "# You may install `requests` to run this code: pip install requests\n",
    "# Please refer to `https://api.fanyi.baidu.com/doc/26` for complete api document\n",
    "\n",
    "import requests\n",
    "import random\n",
    "import json\n",
    "import os\n",
    "import sys\n",
    "from hashlib import md5\n",
    "\n",
    "\n",
    "file_name = '1.jpeg'\n",
    "\n",
    "url = 'https://aip.baidubce.com/file/2.0/mt/pictrans/v1?access_token=【24.ba09e12a29298d6c2f560350991a6375.2592000.1659012356.282335-25869222】'\n",
    "\n",
    "from_lang = 'zh'\n",
    "to_lang = 'en'\n",
    "\n",
    "# Build request\n",
    "payload = {'from': from_lang, 'to': to_lang, 'v': '3', 'paste': '1'}\n",
    "image = {'image': (os.path.basename(file_name), open(file_name, 'rb'), \"multipart/form-data\")}\n",
    "\n",
    "# Send request\n",
    "response = requests.post(url, params = payload, files = image)\n",
    "result = response.json()\n",
    "\n",
    "# Show response\n",
    "print(json.dumps(result, indent = 4, ensure_ascii = False))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "28e75db0",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "725878b9",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "025408d1",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0deee29d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2f5b7f3f",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
